package com.dragonsoftbravo.sqlbuilder.sql.where.builder;

/**
 * Created by DI on 2016/5/15.
 */
public class Condition extends Comp {

    public Condition(StringBuilder sqlBuilder) {
        super(sqlBuilder);
    }

    public static Condition and(Comp operatorBuilder1, Comp operatorBuilder2,Comp ...OtherComps){
        StringBuilder sb = new StringBuilder().append(operatorBuilder1.build()).append(" AND ").append(operatorBuilder2.build());
        for(Comp comp : OtherComps){
            sb.append(" AND "+comp.build());
        }
        return new Condition(sb);
    }

    public static Condition or(Comp operatorBuilder1, Comp operatorBuilder2,Comp ...OtherComps){
        StringBuilder sb = new StringBuilder().append(operatorBuilder1.build()).append(" OR ").append(operatorBuilder2.build());
        for(Comp comp : OtherComps){
            sb.append(" OR "+comp.build());
        }
        return new Condition(sb);
    }

}
